package post

import (
	"time"
	"mdbook/blackfriday"
)

// 页面最新版本，提高查询性能和管理时列表所用
type Snapshot struct {
	Id		int64
	Title 	string
	Content	string
	Author 	string
	Date 	time.Time
	Version	int64
	Path 	string
}

func (snap *Snapshot) Post() *Post {
	return &Post{
		snap.Id,
		snap.Title,
		snap.Content,
		snap.Author,
		snap.Date,
		snap.Version,
	}
}

func (post *Snapshot) ParseHTML(){
	html := blackfriday.MarkdownBasic([]byte(post.Content))
	post.Content = string(html)
	lc := time.FixedZone("UTC", 28800)
	post.Date = post.Date.In(lc)
}
